import org.junit.Test;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class testGeneric {

    @Test
    public void listGeneric() throws IllegalAccessException, InstantiationException {
        ArrayList<String> a = new ArrayList<String>();
        ArrayList b = new ArrayList();
        Class<? extends ArrayList> c1 = a.getClass();
        Type genericSuperclass = c1.getGenericSuperclass();
        Type actualTypeArguments = ((ParameterizedTypeImpl) genericSuperclass).getActualTypeArguments()[0];
        ArrayList arrayList = c1.newInstance();
        Class c2 = b.getClass();
        Object o = c2.newInstance();
        System.out.println(c1 == c2); //true

        Object o1 = new Object();
        List<Object> list = new ArrayList<Object>();
        while (true){
            list.add(new Object());
        }

    }
}
